package com.summatech.gwt.mvp.client.view;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasChangeHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
import com.summatech.gwt.mvp.client.presenter.SenderPresenter.ISenderView;

public class SenderView extends Composite implements ISenderView {

	private static SenderViewUiBinder uiBinder = GWT
			.create(SenderViewUiBinder.class);
	@UiField
	InlineLabel lblGroup;
	@UiField
	ListBox lstBox;

	interface SenderViewUiBinder extends UiBinder<Widget, SenderView> {
	}

	public SenderView() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	public void showGroup(String group) {
		lblGroup.setText(group);
		addStyleName(group);
	}

	public HasChangeHandlers getSelectableComponent() {
		return lstBox;
	}

	public String getSelectedValue() {
		return lstBox.getItemText(lstBox.getSelectedIndex());
	}

	public void displayValues(List<String> values) {
		lstBox.addItem("");
		for (String item : values) {
			lstBox.addItem(item);
		}
	}
}
